package com.wenjiang.config;


import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
@ConfigurationProperties(prefix ="spring.redisson" )
@Data
public class RedissonConfig {


    /**
     *
     */

    private  String address;

    private String password;



    /**
     * 注入锁的客户端 (单体版配置)
     */

    @Bean(destroyMethod = "shutdown")
    RedissonClient redisson(){
        //创建配置
        Config config = new Config();

        config.useSingleServer().setAddress(address).setPassword(password).setTimeout(10000).setPingConnectionInterval(1000);

        return Redisson.create(config);
    }


}
